<?php

namespace app\admin\model;

use think\Model;

/**
 * Withdraw
 */
class Withdraw extends Model
{
    // 表名
    protected $name = 'withdraw';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    protected $updateTime = false;
    protected $type = [
        'check_time' => 'timestamp:Y-m-d H:i:s',
    ];

    protected $staust=[0=>'未知',1=>'待审核','审核通过','审核拒绝'];

    // 追加属性
    protected $append = [
        'status_text',
        'create_time_text',
        'domain_check_img'
    ];
    public function getCreateTimeTextAttr($value,$data)
    {
       if(isset($data['create_time'])){
           return date('Y-m-d H:i:s',$data['create_time']);
       }
       return '-';
    }
    public function getDomainCheckImgAttr($value,$data)
    {
        if(isset($data['check_img'])&&!empty($data['check_img'])){
            return request()->domain().$data['check_img'];
        }else{
            return '';
        }

    }
    public function getStatusTextAttr($value,$data){
        if(isset($data['check_status'])){
            return $this->staust[$data['check_status']];
        }
        return '-';
    }

    public function user(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\User::class, 'user_id', 'id');
    }
}